<template>
  <div class="dv">
    <div class="box">
      <h2>vue-element-admin二开项目-OA后台系统</h2>
      <el-form :model="form">
        <el-form-item>
          <el-input v-model="form.mobile" :prefix-icon="Avatar" />
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.password" :prefix-icon="Unlock" />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="onSubmit"
            style="width: 80%; margin: 20px"
            >登录</el-button
          >
        </el-form-item>
      </el-form>
      <p>账号:13800000002 密码:123456</p>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, toRefs } from "vue";
import { login } from "../http/api";
import { useStore } from "vuex";
import { Avatar, Unlock } from "@element-plus/icons-vue"; //图标

import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const store = useStore();
let { form } = reactive({
  form: {
    mobile: "13800000002",
    password: "123456",
  },
});
const onSubmit = () => {
  login(form).then((res) => {
    console.log(res);
    store.dispatch("user/tologins", res);
    router.push("/");
    store.commit("user/userlogin");
  });
};
</script>

<style lang="scss">
.dv {
  width: 100vw;
  height: 100vh;
  background: #458cfe;
  overflow: hidden;
  color: #fff;
  .box {
    width: 500px;
    height: 400px;
    background: #458cfe;
    margin: 150px auto;
  }
}

.el-input {
  margin: 20px;
}
</style>
